import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
import { CommonEntity, CommonStatus } from '~/common/entity/common.entity';
import { UserEntity } from '~/modules/user/user.entity';
import { ApiProperty } from '@nestjs/swagger';

export enum FeedbackType {
  BUG = 'BUG', // 功能异常
  FEATURE = 'FEATURE', // 功能建议
  UI = 'UI', // 界面建议
  OTHER = 'OTHER', // 其他
}

export enum FeedbackStatus {
  NEW = 'NEW', // 新建
  PROCESSING = 'PROCESSING', // 处理中
  COMPLETED = 'COMPLETED', // 已完成
  REJECTED = 'REJECTED', // 已拒绝
}

@Entity('ah_feedback')
@Index(['id'])
export class FeedbackEntity extends CommonEntity {
  @ApiProperty({ description: '反馈内容' })
  @Column({ type: 'text', comment: '反馈内容' })
  content: string;

  @ApiProperty({ description: '反馈类型' })
  @Column({
    type: 'enum',
    enum: FeedbackType,
    default: FeedbackType.FEATURE,
    comment: '反馈类型',
  })
  type: FeedbackType;

  @ApiProperty({ description: '反馈状态' })
  @Column({
    type: 'enum',
    enum: FeedbackStatus,
    default: FeedbackStatus.NEW,
    comment: '反馈状态',
  })
  status: FeedbackStatus;

  @ApiProperty({ description: '回复内容', nullable: true })
  @Column({
    type: 'text',
    comment: '回复内容',
    nullable: true,
    name: 'reply_content',
  })
  replyContent: string;

  @ApiProperty({ description: '处理人ID', nullable: true })
  @Column({
    type: 'int',
    comment: '处理人ID',
    nullable: true,
    name: 'handler_id',
  })
  handlerId: number;

  @ApiProperty({ description: '处理时间', nullable: true })
  @Column({
    type: 'datetime',
    comment: '处理时间',
    nullable: true,
    name: 'handle_time',
  })
  handleTime: Date;

  @ApiProperty({ description: '是否已删除' })
  @Column({
    type: 'tinyint',
    width: 1,
    default: CommonStatus.NO,
    comment: '是否已删除',
    name: 'is_deleted',
  })
  isDeleted: number;

  @Column({ name: 'user_id', type: 'int', comment: '用户ID', nullable: true })
  userId: number
}